package org.jeecg.modules.flowable.system.etc;

import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.flowable.common.util.validation.AssertValid;
import org.jeecg.modules.flowable.system.core.SystemUser;

/**
 * Title:  <br>
 * Desc:  <br>
 * Date: 6/26/22 2:48 PM <br>
 * Company: 联通（辽宁）产业互联网有限公司 <br>
 *
 * @author zxd
 * @version 1.0.0
 */
public class SystemUserUtil {

    /**
     * 获得系统用户
     *
     * @return
     */
    public static SystemUser getSystemUser() {
        // 和三方系统对接用户体系，
        try {
            LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
            if (AssertValid.isNotEmpty(loginUser)) {
                SystemUser systemUser = new SystemUser().setId(loginUser.getId()).setRealname(loginUser.getRealname());
                return systemUser;
            } else {
                SystemUser systemUser = new SystemUser().setId("").setRealname("");
                return systemUser;
            }
        } catch (Exception e) {
            SystemUser systemUser = new SystemUser().setId("").setRealname("");
            return systemUser;
        }

    }
}